Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Compatibility rules
Since an object reference and a procedure handle represent two very different constructs in Progress, the following rules apply when working with both:
- You cannot run r-code for a class using the
RUNstatement. You must use theNEWstatement to create a class instance.- You can only use the
NEWstatement to create an instance of a class. You cannot use theNEWstatement to run a persistent procedure.- An instance of a class never has a procedure object handle associated with it. Thus, a class does not use system handles, such as
THIS-PROCEDUREorTARGET-PROCEDURE, that return procedure object handles for referencing the r-code of a referencing procedure. Using any of these keywords in a class results in a compile-time error.- A procedure has no notion of a class or object reference. Thus a procedure cannot use keywords, such as
THIS-OBJECT, that return references to the r-code of a referencing class or class hierarchy. Using any of these keywords in a procedure results in a compile-time error.- You cannot assign a procedure handle to an object reference. You cannot assign an object reference to a procedure handle. Thus, while you can cast object references from one to another, you cannot cast an object reference to a procedure handle or in any way convert one to the other.
- You cannot pass an object reference to a routine expecting a procedure handle. Likewise, you cannot pass a procedure handle to a routine expecting an object reference. As noted, there is no way to cast a procedure handle to an object reference or an object reference to a procedure handle.
- You cannot define methods in a procedure. Procedures define their internal entry points as internal procedures or user-defined functions only. You can define methods only in classes. Likewise, you cannot define internal procedure or user-defined functions in procedures, but only in external procedures.
- You cannot use the
object-reference:method-namesyntax to run an internal procedure or a function, but only a method. You can use this syntax, however, in both classes and procedures.- You cannot define a constructor or destructor for a procedure. You can define these special methods only for classes.
- You cannot use a
PUBLIC,PRIVATE, orPROTECTEDaccess modifier on a variable or other data member definition except in the main block of a class.- You cannot use the 4GL built-in
ADD-SUPER-PROCEDURE( )method on theTHIS-OBJECTsystem reference or theTHIS-PROCEDUREsystem handle within a class or otherwise use the super procedure mechanism to create a hierarchy of object references. Thus, you cannot add a class-based object as a super procedure. However within a class, you can use theSESSION:ADD-SUPER-PROCEDURE( )method to extend the super procedure chain of theSESSIONhandle, and you can use theprocedure-handle:ADD-SUPER-PROCEDURE( )method, whereprocedure-handleis a procedure object handle set from running a persistent procedure, in order to extend the super procedure chain for other, procedure-based objects.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |